summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-06-03 19:12:31 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-06-09 15:20:18 -0400
commit5c4be4057a8ececee7d260623fdc58f09ee4a09d (patch)
tree62f8b3540ada9c3422ba22908aa6be42b7a4624f /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentd70c0e344d420af1d8520b0a73109850f66c518c (diff)
downloadscala-5c4be4057a8ececee7d260623fdc58f09ee4a09d.tar.gz
scala-5c4be4057a8ececee7d260623fdc58f09ee4a09d.tar.bz2
scala-5c4be4057a8ececee7d260623fdc58f09ee4a09d.zip
SI-7364 Allow raw types in parent position in Java sources
To make this work, this commit simply restricts parent type argument inference to Scala source files. The surrounding code has also been refactored to avoid a var.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 238727d2e9..3d3d7e26ff 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1571,9 +1571,9 @@ trait Typers extends Adaptations with Tags {
}
typedType(decodedtpt)
} else {
- var supertpt = typedTypeConstructor(decodedtpt)
+ val supertpt = typedTypeConstructor(decodedtpt)
val supertparams = if (supertpt.hasSymbolField) supertpt.symbol.typeParams else Nil
- if (supertparams.nonEmpty) {
+ def inferParentTypeArgs: Tree = {
typedPrimaryConstrBody(templ) {
val supertpe = PolyType(supertparams, appliedType(supertpt.tpe, supertparams map (_.tpeHK)))
val supercall = New(supertpe, mmap(argss)(_.duplicate))
@@ -1581,14 +1581,17 @@ trait Typers extends Adaptations with Tags {
ctor setType supertpe // this is an essential hack, otherwise it will occasionally fail to typecheck
atPos(supertpt.pos.focus)(supercall)
} match {
- case EmptyTree => MissingTypeArgumentsParentTpeError(supertpt)
- case tpt => supertpt = TypeTree(tpt.tpe) setPos supertpt.pos // SI-7224: don't .focus positions of the TypeTree of a parent that exists in source
+ case EmptyTree => MissingTypeArgumentsParentTpeError(supertpt); supertpt
+ case tpt => TypeTree(tpt.tpe) setPos supertpt.pos // SI-7224: don't .focus positions of the TypeTree of a parent that exists in source
}
}
+
+ val supertptWithTargs = if (supertparams.isEmpty || context.unit.isJava) supertpt else inferParentTypeArgs
+
// this is the place where we tell the typer what argss should be used for the super call
// if argss are nullary or empty, then (see the docs for `typedPrimaryConstrBody`)
// the super call dummy is already good enough, so we don't need to do anything
- if (argssAreTrivial) supertpt else supertpt updateAttachment SuperArgsAttachment(argss)
+ if (argssAreTrivial) supertptWithTargs else supertptWithTargs updateAttachment SuperArgsAttachment(argss)
}
}