Permalink
Browse files

Fixes SI-5564.

Catching typer errors in specialization.
  • Loading branch information...
Aleksandar Prokopec Aleksandar Prokopec
Aleksandar Prokopec authored and Aleksandar Prokopec committed May 8, 2012
1 parent c4590b7 commit d107527434b6cdf5f3ec6900a9572d6a6e3e5629
@@ -1322,7 +1322,15 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
else None
} else None
}
def reportError[T](body: =>T)(handler: TypeError => T): T =
try body
catch {
case te: TypeError =>
reporter.error(tree.pos, te.msg)
handler(te)
}
curTree = tree
tree match {
case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) =>
@@ -1331,11 +1339,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
if (found.typeSymbol ne tpt.tpe.typeSymbol) {
// the ctor can be specialized
debuglog("** instantiated specialized type: " + found)
try localTyper.typedPos(tree.pos)(New(found, transformTrees(args): _*))
catch {
case te: TypeError =>
reporter.error(tree.pos, te.msg)
super.transform(tree)
reportError {
localTyper.typedPos(tree.pos)(New(found, transformTrees(args): _*))
} {
_ => super.transform(tree)
}
} else super.transform(tree)
@@ -1493,13 +1500,21 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
})
debuglog("created special overload tree " + t)
debuglog("created " + t)
localTyper.typed(t)
reportError {
localTyper.typed(t)
} {
_ => super.transform(tree)
}
case fwd @ Forward(_) =>
debuglog("forward: " + fwd + ", " + ddef)
val rhs1 = forwardCall(tree.pos, gen.mkAttributedRef(symbol.owner.thisType, fwd.target), vparamss)
debuglog("-->d completed forwarder to specialized overload: " + fwd.target + ": " + rhs1)
localTyper.typed(deriveDefDef(tree)(_ => rhs1))
reportError {
localTyper.typed(deriveDefDef(tree)(_ => rhs1))
} {
_ => super.transform(tree)
}
case SpecializedAccessor(target) =>
val rhs1 = if (symbol.isGetter)
@@ -0,0 +1,4 @@
t5564.scala:8: error: inferred type arguments [A] do not conform to method bar's type parameter bounds [B >: A <: C]
def bar[B >: A <: C]: T = throw new Exception
^
one error found
File renamed without changes.

0 comments on commit d107527

Please sign in to comment.