changeset 749:b3cc870e2c67

Bug fixes: *) Regression: type-variables not visible when default implementation of generic extension method is lazily attributed *) Misc bugs causing compiler to generate classfiles in wrong location (caused some spurious regression failures when tests were run twice w/o cleanup)
author mcimadamore
date Mon, 08 Nov 2010 12:40:38 +0000
parents cd26d488d641
children f5c76a5c84e3
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/share/classes/com/sun/tools/javac/comp/Unlambda.java test/tools/javac/defender/Pos10.java
diffstat 4 files changed, 53 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Oct 29 18:11:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Nov 08 12:40:38 2010 +0000
@@ -2057,6 +2057,7 @@
 
         ClassSymbol lambdaClassSym =
                     new ClassSymbol(flags, names.empty, null, owner);
+        lambdaClassSym.sourcefile = env.enclClass.sym.sourcefile;
 
         lambdaClassSym.type = new ClassType(Type.noType,
                 List.<Type>nil(),
@@ -2064,6 +2065,9 @@
 
         enter.setEnclosingType(lambdaClassSym, lambdaClassSym.owner);
 
+        lambdaClassSym.flatname = chk.localClassName(lambdaClassSym);
+        chk.compiled.put(lambdaClassSym.flatname, lambdaClassSym);
+
         if (lambdaClassSym.type.getEnclosingType().tag != NONE) {
             lambdaClassSym.flags_field |= OUTER_ACCESS;            
         }
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Oct 29 18:11:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Nov 08 12:40:38 2010 +0000
@@ -580,7 +580,12 @@
                         //enter method params in local scope (needed in order
                         //to attribute fake defender body)
                         for (Symbol param : params) {
-                            localEnv.info.scope.enter(param);
+                            localEnv.info.scope.enterIfAbsent(param);
+                        }
+                        //enter method typevars in local scope (needed in order
+                        //to attribute fake defender body)
+                        for (JCTypeParameter typevar : tree.typarams) {
+                            localEnv.info.scope.enterIfAbsent(typevar.type.tsym);
                         }
                         attr.attribStat(tree.body, localEnv);
                         if (tree.body.stats.head.getTag() != JCTree.EXEC ||
--- a/src/share/classes/com/sun/tools/javac/comp/Unlambda.java	Fri Oct 29 18:11:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Unlambda.java	Mon Nov 08 12:40:38 2010 +0000
@@ -113,9 +113,6 @@
                     samClassSym.type,
                     samClassSym);
         samClassSym.members().enter(thisSym);
-        
-        samClassSym.flatname = chk.localClassName(samClassSym);
-        chk.compiled.put(samClassSym.flatname, samClassSym);
 
         Type superType = types.isFunctionType(tree.targetType) ?
             syms.methodHandleType :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defender/Pos10.java	Mon Nov 08 12:40:38 2010 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary check that type-variables in generic extension decl can be accessed from default impl
+ * @author  Maurizio Cimadamore
+ * @compile Pos10.java
+ */
+
+class Pos10 {
+    interface Function<X,Y> {
+        Y apply(X x);
+    }
+
+    interface A<T> {
+        <R> extension void m(Function<T,R> f) default Impl.<T,R>m;
+    }
+
+    static class Impl {
+        static <T,R> void m(A<T> a, Function<T,R> f) {  }
+    }
+}