From 9042aa6cc839ffa7e938c1e7daec23b41dafed4d Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 29 Jan 2013 15:07:52 +0100 Subject: [PATCH 1/2] SI-7308 A pending test. To be remedied in the followup commit. --- test/pending/run/t7308.check | 30 ++++++++++++++++++++++++++++++ test/pending/run/t7308.scala | 14 ++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/pending/run/t7308.check create mode 100644 test/pending/run/t7308.scala diff --git a/test/pending/run/t7308.check b/test/pending/run/t7308.check new file mode 100644 index 000000000000..42a3ea546130 --- /dev/null +++ b/test/pending/run/t7308.check @@ -0,0 +1,30 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> def foo[S] = { type X = List[S]; List():X } +foo: [S]=> X + +scala> val li = foo[Int] +li: X = List() + +scala> li: List[Int] +:10: error: type mismatch; + found : X + (which expands to) List[S] + required: List[Int] + li: List[Int] + ^ + +scala> type TL = List[Int] +defined type alias TL + +scala> def foo = null: TL +foo: TL + +scala> def foo = {type TL=List[Int]; null: TL} +foo: TL + +scala> foo: List[Int] +res1: List[Int] = null + +scala> diff --git a/test/pending/run/t7308.scala b/test/pending/run/t7308.scala new file mode 100644 index 000000000000..8d9fd2e9e4eb --- /dev/null +++ b/test/pending/run/t7308.scala @@ -0,0 +1,14 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + + override def code = """ +def foo[S] = { type X = List[S]; List():X } +val li = foo[Int] +li: List[Int] +type TL = List[Int] +def foo = null: TL +def foo = {type TL=List[Int]; null: TL} +foo: List[Int] + """.trim +} \ No newline at end of file From fe99eb34313d591c83de093738c1d2c8e768ac6f Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 29 Jan 2013 15:10:25 +0100 Subject: [PATCH 2/2] SI-7038 Deskolemize harder Inferred method return types can contain skolems for the methods type parameters seen from within the method body. `Namer#typeSig` deskolemized these, replacing the skolems with the type parameter symbols. This failed to deskolemize the underlying type of a by a method-local type alias. This commit changes deskolemizeMap to normalize types along the way. --- .../reflect/internal/ExistentialsAndSkolems.scala | 2 ++ test/{pending => files}/run/t7308.check | 11 +++-------- test/{pending => files}/run/t7308.scala | 0 3 files changed, 5 insertions(+), 8 deletions(-) rename test/{pending => files}/run/t7308.check (68%) rename test/{pending => files}/run/t7308.scala (100%) diff --git a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala index 59c027868eaa..0e483d27bf9b 100644 --- a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala +++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala @@ -41,6 +41,8 @@ trait ExistentialsAndSkolems { def apply(tp: Type): Type = tp match { case TypeRef(pre, sym, args) if sym.isTypeSkolem && (tparams contains sym.deSkolemize) => mapOver(typeRef(NoPrefix, sym.deSkolemize, args)) + case TypeRef(pre, sym, args) if sym.isAliasType => + mapOver(tp.normalize) case _ => mapOver(tp) } diff --git a/test/pending/run/t7308.check b/test/files/run/t7308.check similarity index 68% rename from test/pending/run/t7308.check rename to test/files/run/t7308.check index 42a3ea546130..573539319e8c 100644 --- a/test/pending/run/t7308.check +++ b/test/files/run/t7308.check @@ -2,18 +2,13 @@ Type in expressions to have them evaluated. Type :help for more information. scala> def foo[S] = { type X = List[S]; List():X } -foo: [S]=> X +foo: [S]=> List[S] scala> val li = foo[Int] -li: X = List() +li: List[Int] = List() scala> li: List[Int] -:10: error: type mismatch; - found : X - (which expands to) List[S] - required: List[Int] - li: List[Int] - ^ +res0: List[Int] = List() scala> type TL = List[Int] defined type alias TL diff --git a/test/pending/run/t7308.scala b/test/files/run/t7308.scala similarity index 100% rename from test/pending/run/t7308.scala rename to test/files/run/t7308.scala