@@ -2048,7 +2048,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2048
2048
} else tpt1.tpe
2049
2049
transformedOrTyped(vdef.rhs, EXPRmode | BYVALmode , tpt2)
2050
2050
}
2051
- val vdef1 = treeCopy.ValDef (vdef, typedMods, sym.name, tpt1, checkDead(rhs1)) setType NoType
2051
+ val vdef1 = treeCopy.ValDef (vdef, typedMods, sym.name, tpt1, checkDead(context, rhs1)) setType NoType
2052
2052
if (sym.isSynthetic && sym.name.startsWith(nme.RIGHT_ASSOC_OP_PREFIX ))
2053
2053
rightAssocValDefs += ((sym, vdef1.rhs))
2054
2054
vdef1
@@ -2282,7 +2282,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2282
2282
}
2283
2283
2284
2284
if (tpt1.tpe.typeSymbol != NothingClass && ! context.returnsSeen && rhs1.tpe.typeSymbol != NothingClass )
2285
- rhs1 = checkDead(rhs1)
2285
+ rhs1 = checkDead(context, rhs1)
2286
2286
2287
2287
if (! isPastTyper && meth.owner.isClass &&
2288
2288
meth.paramss.exists(ps => ps.exists(_.hasDefault) && isRepeatedParamType(ps.last.tpe)))
@@ -2528,7 +2528,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2528
2528
2529
2529
// takes untyped sub-trees of a match and type checks them
2530
2530
def typedMatch (selector : Tree , cases : List [CaseDef ], mode : Mode , pt : Type , tree : Tree = EmptyTree ): Match = {
2531
- val selector1 = checkDead(typedByValueExpr(selector))
2531
+ val selector1 = checkDead(context, typedByValueExpr(selector))
2532
2532
val selectorTp = packCaptured(selector1.tpe.widen).skolemizeExistential(context.owner, selector)
2533
2533
val casesTyped = typedCases(cases, selectorTp, pt)
2534
2534
@@ -3104,7 +3104,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3104
3104
else newTyper(context.make(stat, exprOwner))
3105
3105
// XXX this creates a spurious dead code warning if an exception is thrown
3106
3106
// in a constructor, even if it is the only thing in the constructor.
3107
- val result = checkDead(localTyper.typedByValueExpr(stat))
3107
+ val result = checkDead(context, localTyper.typedByValueExpr(stat))
3108
3108
3109
3109
if (treeInfo.isSelfOrSuperConstrCall(result)) {
3110
3110
context.inConstructorSuffix = true
@@ -3265,7 +3265,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3265
3265
def typedArg (arg : Tree , mode : Mode , newmode : Mode , pt : Type ): Tree = {
3266
3266
val typedMode = mode.onlySticky | newmode
3267
3267
val t = withCondConstrTyper(mode.inSccMode)(_.typed(arg, typedMode, pt))
3268
- checkDead.inMode(typedMode, t)
3268
+ checkDead.inMode(context, typedMode, t)
3269
3269
}
3270
3270
3271
3271
def typedArgs (args : List [Tree ], mode : Mode ) =
@@ -3662,9 +3662,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3662
3662
else
3663
3663
constfold(treeCopy.Apply (tree, fun, args2) setType ifPatternSkipFormals(restpe))
3664
3664
}
3665
- checkDead.updateExpr(fun) {
3666
- handleMonomorphicCall
3667
- }
3665
+ if (settings.warnDeadCode) {
3666
+ val sym = fun.symbol
3667
+ if (sym != null && sym.isMethod && ! sym.isConstructor) {
3668
+ val suppress = sym == Object_synchronized || (sym.isLabel && treeInfo.isSynthCaseSymbol(sym))
3669
+ context.withSuppressDeadArgWarning(suppress) {
3670
+ handleMonomorphicCall
3671
+ }
3672
+ } else handleMonomorphicCall
3673
+ } else handleMonomorphicCall
3668
3674
} else if (needsInstantiation(tparams, formals, args)) {
3669
3675
// println("needs inst "+fun+" "+tparams+"/"+(tparams map (_.info)))
3670
3676
inferExprInstance(fun, tparams)
@@ -4433,7 +4439,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4433
4439
// (phase.erasedTypes && varsym.isValue && !varsym.isMethod)) {
4434
4440
if (varsym.isVariable || varsym.isValue && phase.assignsFields) {
4435
4441
val rhs1 = typedByValueExpr(rhs, lhs1.tpe)
4436
- treeCopy.Assign (tree, lhs1, checkDead(rhs1)) setType UnitTpe
4442
+ treeCopy.Assign (tree, lhs1, checkDead(context, rhs1)) setType UnitTpe
4437
4443
}
4438
4444
else if (dyna.isDynamicallyUpdatable(lhs1)) {
4439
4445
val t = atPos(lhs1.pos.withEnd(rhs.pos.end)) {
@@ -4445,7 +4451,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4445
4451
}
4446
4452
4447
4453
def typedIf (tree : If ): If = {
4448
- val cond1 = checkDead(typedByValueExpr(tree.cond, BooleanTpe ))
4454
+ val cond1 = checkDead(context, typedByValueExpr(tree.cond, BooleanTpe ))
4449
4455
// One-legged ifs don't need a lot of analysis
4450
4456
if (tree.elsep.isEmpty)
4451
4457
return treeCopy.If (tree, cond1, typed(tree.thenp, UnitTpe ), tree.elsep) setType UnitTpe
@@ -4533,7 +4539,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4533
4539
if (typed(expr).tpe.typeSymbol != UnitClass )
4534
4540
context.warning(tree.pos, " enclosing method " + name + " has result type Unit: return value discarded" )
4535
4541
}
4536
- val res = treeCopy.Return (tree, checkDead(expr1)).setSymbol(enclMethod.owner)
4542
+ val res = treeCopy.Return (tree, checkDead(context, expr1)).setSymbol(enclMethod.owner)
4537
4543
val tp = pluginsTypedReturn(NothingTpe , this , res, restpt.tpe)
4538
4544
res.setType(tp)
4539
4545
}
@@ -5104,7 +5110,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
5104
5110
typedSelect(tree, qualStableOrError, name)
5105
5111
} else {
5106
5112
if (StatisticsStatics .areSomeColdStatsEnabled) statistics.incCounter(typedSelectCount)
5107
- val qualTyped = checkDead(typedQualifier(qual, mode))
5113
+ val qualTyped = checkDead(context, typedQualifier(qual, mode))
5108
5114
val tree1 = typedSelect(tree, qualTyped, name)
5109
5115
5110
5116
if (tree.isInstanceOf [PostfixSelect ])
@@ -5406,7 +5412,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
5406
5412
if (funTyped.tpe.isInstanceOf [OverloadedType ]) inferExprAlternative(funTyped, pt)
5407
5413
funTyped match {
5408
5414
case macroDef if treeInfo.isMacroApplication(macroDef) => MacroEtaError (macroDef)
5409
- case methodValue => typedEta(checkDead(methodValue))
5415
+ case methodValue => typedEta(checkDead(context, methodValue))
5410
5416
}
5411
5417
case Typed (expr, tpt) =>
5412
5418
val tpt1 = typedType(tpt, mode) // type the ascribed type first
0 commit comments