diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-23 18:16:01 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-23 18:30:23 +0200 |
commit | e6912050bf6132cbe6338ce1d6786703757575ce (patch) | |
tree | ef355f7afa1b0f97b9b790f56ff32678f63f1963 | |
parent | 3bcd6f8cb5ad63dff3514fd2d74fdcc23959bec2 (diff) | |
download | scala-e6912050bf6132cbe6338ce1d6786703757575ce.tar.gz scala-e6912050bf6132cbe6338ce1d6786703757575ce.tar.bz2 scala-e6912050bf6132cbe6338ce1d6786703757575ce.zip |
SI-2038 make pt fully-defined when typing Typed
dropExistential turns existentials in the expected type (pt) that's passed to `typed`
into `BoundedWildcardType`s, but those should not end up in trees
when typing a `Typed` node, we didn't check for the type being fully defined (`isFullyDefined`)
(and thus did not make it fully defined by turning these BWTs into existentials again using `makeFullyDefined`)
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t2038.scala | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index dbe65c16d8..9e498a3012 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4980,7 +4980,9 @@ trait Typers extends Modes with Adaptations with Tags { if (isPatternMode) { val uncheckedTypeExtractor = extractorForUncheckedType(tpt.pos, tptTyped.tpe) val ownType = inferTypedPattern(tptTyped, tptTyped.tpe, pt, canRemedy = uncheckedTypeExtractor.nonEmpty) - treeTyped setType ownType + // println(s"Typed($expr, ${tpt.tpe}) : $pt --> $ownType (${isFullyDefined(ownType)}, ${makeFullyDefined(ownType)})") + // make fully defined to avoid bounded wildcard types that may be in pt from calling dropExistential (SI-2038) + treeTyped setType (if (isFullyDefined(ownType)) ownType else makeFullyDefined(ownType)) //ownType uncheckedTypeExtractor match { case None => treeTyped diff --git a/test/files/pos/t2038.scala b/test/files/pos/t2038.scala new file mode 100644 index 0000000000..17b1a702dd --- /dev/null +++ b/test/files/pos/t2038.scala @@ -0,0 +1,5 @@ +class Test { + List(Some(classOf[java.lang.Integer]), Some(classOf[Int])).map { + case Some(f: Class[_]) => f.cast(???) + } +}
\ No newline at end of file |