diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 5 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 12 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 3 | ||||
-rw-r--r-- | test/files/pos/sammy_single.flags | 1 | ||||
-rw-r--r-- | test/files/pos/sammy_single.scala | 9 |
5 files changed, 18 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index d97f62d5d6..ccf2266540 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -85,9 +85,6 @@ abstract class UnCurry extends InfoTransform transformFunction(result) } - private lazy val serialVersionUIDAnnotation = - AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List()) - // I don't have a clue why I'm catching TypeErrors here, but it's better // than spewing stack traces at end users for internal errors. Examples // which hit at this point should not be hard to come by, but the immediate @@ -220,7 +217,7 @@ abstract class UnCurry extends InfoTransform case fun1 if fun1 ne fun => fun1 case _ => val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe)) - val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation serialVersionUIDAnnotation + val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation anonClass setInfo ClassInfoType(parents, newScope, anonClass) val targs = fun.tpe.typeArgs diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8e74ae3e0b..2ca858b732 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2498,9 +2498,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // targs must conform to Any for us to synthesize an applyOrElse (fallback to apply otherwise -- typically for @cps annotated targs) val targsValidParams = targs forall (_ <:< AnyTpe) - val anonClass = (context.owner - newAnonymousFunctionClass tree.pos - addAnnotation AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List())) + val anonClass = context.owner newAnonymousFunctionClass tree.pos addAnnotation SerialVersionUIDAnnotation import CODE._ @@ -2795,19 +2793,19 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // solve constraints tracked by tvars val targs = solvedTypes(tvars, tparams, tparams map varianceInType(sam.info), upper = false, lubDepth(sam.info :: Nil)) - debuglog(s"sam infer: $samClassTp --> ${appliedType(samTyCon, targs)} by ${actualSamType} <:< ${expectedSamType} --> $targs for $tparams") + debuglog(s"sam infer: $samClassTp --> ${appliedType(samTyCon, targs)} by $actualSamType <:< $expectedSamType --> $targs for $tparams") // a fully defined samClassTp appliedType(samTyCon, targs) } catch { case _: NoInstance | _: TypeError => - println("TODO: OOPS") + devWarning(sampos, s"Could not define type $samClassTp using ${samBodyDef.symbol.rawInfo} <:< ${samClassTp memberInfo sam} (for $sam)") samClassTp } // `final override def ${sam.name}($p1: $T1, ..., $pN: $TN): $resPt = ${sam.name}\$body'($p1, ..., $pN)` val samDef = - DefDef(Modifiers(FINAL | OVERRIDE), + DefDef(Modifiers(FINAL | OVERRIDE | SYNTHETIC), sam.name.toTermName, Nil, List(fun.vparams), @@ -2842,7 +2840,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper ) } - classDef.symbol addAnnotation AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List()) + classDef.symbol addAnnotation SerialVersionUIDAnnotation block } diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 6fb99b9a5b..5970514102 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -750,7 +750,7 @@ trait Definitions extends api.StandardDefinitions { // must filter out "universal" members (getClass is deferred for some reason) val deferredMembers = ( tp membersBasedOnFlags (excludedFlags = BridgeAndPrivateFlags, requiredFlags = METHOD) - filter (mem => mem.isDeferred && !isUniversalMember(mem)) + filter (mem => mem.isDeferredNotDefault && !isUniversalMember(mem)) // TODO: test ) // if there is only one, it's monomorphic and has a single argument list @@ -1052,6 +1052,7 @@ trait Definitions extends api.StandardDefinitions { lazy val ScalaInlineClass = requiredClass[scala.inline] lazy val ScalaNoInlineClass = requiredClass[scala.noinline] lazy val SerialVersionUIDAttr = requiredClass[scala.SerialVersionUID] + lazy val SerialVersionUIDAnnotation = AnnotationInfo(SerialVersionUIDAttr.tpe, List(Literal(Constant(0))), List()) lazy val SpecializedClass = requiredClass[scala.specialized] lazy val ThrowsClass = requiredClass[scala.throws[_]] lazy val TransientAttr = requiredClass[scala.transient] diff --git a/test/files/pos/sammy_single.flags b/test/files/pos/sammy_single.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/pos/sammy_single.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/pos/sammy_single.scala b/test/files/pos/sammy_single.scala new file mode 100644 index 0000000000..7a3d272983 --- /dev/null +++ b/test/files/pos/sammy_single.scala @@ -0,0 +1,9 @@ +// test that dependent types work +// TODO: def apply(x: String): x.type does NOT work yet +object Test { + val s: String = "" + + trait T { def apply(x: s.type): s.type } + + val preservedResult: s.type = ((x => x): T)(s) +}
\ No newline at end of file |