@@ -2086,7 +2086,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2086
2086
} else tpt1.tpe
2087
2087
transformedOrTyped(vdef.rhs, EXPRmode | BYVALmode , tpt2)
2088
2088
}
2089
- treeCopy.ValDef (vdef, typedMods, sym.name, tpt1, checkDead(rhs1)) setType NoType
2089
+ treeCopy.ValDef (vdef, typedMods, sym.name, tpt1, checkDead(context, rhs1)) setType NoType
2090
2090
}
2091
2091
2092
2092
/** Enter all aliases of local parameter accessors.
@@ -2317,7 +2317,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2317
2317
}
2318
2318
2319
2319
if (tpt1.tpe.typeSymbol != NothingClass && ! context.returnsSeen && rhs1.tpe.typeSymbol != NothingClass )
2320
- rhs1 = checkDead(rhs1)
2320
+ rhs1 = checkDead(context, rhs1)
2321
2321
2322
2322
if (! isPastTyper && meth.owner.isClass &&
2323
2323
meth.paramss.exists(ps => ps.exists(_.hasDefault) && isRepeatedParamType(ps.last.tpe)))
@@ -2557,7 +2557,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
2557
2557
2558
2558
// takes untyped sub-trees of a match and type checks them
2559
2559
def typedMatch (selector : Tree , cases : List [CaseDef ], mode : Mode , pt : Type , tree : Tree = EmptyTree ): Match = {
2560
- val selector1 = checkDead(typedByValueExpr(selector))
2560
+ val selector1 = checkDead(context, typedByValueExpr(selector))
2561
2561
val selectorTp = packCaptured(selector1.tpe.widen).skolemizeExistential(context.owner, selector)
2562
2562
val casesTyped = typedCases(cases, selectorTp, pt)
2563
2563
@@ -3126,7 +3126,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3126
3126
else newTyper(context.make(stat, exprOwner))
3127
3127
// XXX this creates a spurious dead code warning if an exception is thrown
3128
3128
// in a constructor, even if it is the only thing in the constructor.
3129
- val result = checkDead(localTyper.typedByValueExpr(stat))
3129
+ val result = checkDead(context, localTyper.typedByValueExpr(stat))
3130
3130
3131
3131
if (treeInfo.isSelfOrSuperConstrCall(result)) {
3132
3132
context.inConstructorSuffix = true
@@ -3288,7 +3288,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3288
3288
def typedArg (arg : Tree , mode : Mode , newmode : Mode , pt : Type ): Tree = {
3289
3289
val typedMode = mode.onlySticky | newmode
3290
3290
val t = withCondConstrTyper(mode.inSccMode)(_.typed(arg, typedMode, pt))
3291
- checkDead.inMode(typedMode, t)
3291
+ checkDead.inMode(context, typedMode, t)
3292
3292
}
3293
3293
3294
3294
def typedArgs (args : List [Tree ], mode : Mode ) =
@@ -3657,9 +3657,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
3657
3657
else
3658
3658
constfold(treeCopy.Apply (tree, fun, args1) setType ifPatternSkipFormals(restpe))
3659
3659
}
3660
- checkDead.updateExpr(fun) {
3661
- handleMonomorphicCall
3662
- }
3660
+ if (settings.warnDeadCode) {
3661
+ val sym = fun.symbol
3662
+ if (sym != null && sym.isMethod && ! sym.isConstructor) {
3663
+ val suppress = sym == Object_synchronized || (sym.isLabel && treeInfo.isSynthCaseSymbol(sym))
3664
+ context.withSuppressDeadArgWarning(suppress) {
3665
+ handleMonomorphicCall
3666
+ }
3667
+ } else handleMonomorphicCall
3668
+ } else handleMonomorphicCall
3663
3669
} else if (needsInstantiation(tparams, formals, args)) {
3664
3670
// println("needs inst "+fun+" "+tparams+"/"+(tparams map (_.info)))
3665
3671
inferExprInstance(fun, tparams)
@@ -4406,7 +4412,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4406
4412
// (phase.erasedTypes && varsym.isValue && !varsym.isMethod)) {
4407
4413
if (varsym.isVariable || varsym.isValue && phase.assignsFields) {
4408
4414
val rhs1 = typedByValueExpr(rhs, lhs1.tpe)
4409
- treeCopy.Assign (tree, lhs1, checkDead(rhs1)) setType UnitTpe
4415
+ treeCopy.Assign (tree, lhs1, checkDead(context, rhs1)) setType UnitTpe
4410
4416
}
4411
4417
else if (dyna.isDynamicallyUpdatable(lhs1)) {
4412
4418
val t = atPos(lhs1.pos.withEnd(rhs.pos.end)) {
@@ -4418,7 +4424,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4418
4424
}
4419
4425
4420
4426
def typedIf (tree : If ): If = {
4421
- val cond1 = checkDead(typedByValueExpr(tree.cond, BooleanTpe ))
4427
+ val cond1 = checkDead(context, typedByValueExpr(tree.cond, BooleanTpe ))
4422
4428
// One-legged ifs don't need a lot of analysis
4423
4429
if (tree.elsep.isEmpty)
4424
4430
return treeCopy.If (tree, cond1, typed(tree.thenp, UnitTpe ), tree.elsep) setType UnitTpe
@@ -4506,7 +4512,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4506
4512
if (typed(expr).tpe.typeSymbol != UnitClass )
4507
4513
context.warning(tree.pos, " enclosing method " + name + " has result type Unit: return value discarded" )
4508
4514
}
4509
- val res = treeCopy.Return (tree, checkDead(expr1)).setSymbol(enclMethod.owner)
4515
+ val res = treeCopy.Return (tree, checkDead(context, expr1)).setSymbol(enclMethod.owner)
4510
4516
val tp = pluginsTypedReturn(NothingTpe , this , res, restpt.tpe)
4511
4517
res.setType(tp)
4512
4518
}
@@ -5060,7 +5066,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
5060
5066
typedSelect(tree, qualStableOrError, name)
5061
5067
} else {
5062
5068
if (StatisticsStatics .areSomeColdStatsEnabled) statistics.incCounter(typedSelectCount)
5063
- val qualTyped = checkDead(typedQualifier(qual, mode))
5069
+ val qualTyped = checkDead(context, typedQualifier(qual, mode))
5064
5070
val tree1 = typedSelect(tree, qualTyped, name)
5065
5071
5066
5072
if (tree.isInstanceOf [PostfixSelect ])
@@ -5352,7 +5358,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
5352
5358
case MethodValue (expr) =>
5353
5359
typed1(suppressMacroExpansion(expr), mode, pt) match {
5354
5360
case macroDef if treeInfo.isMacroApplication(macroDef) => MacroEtaError (macroDef)
5355
- case methodValue => typedEta(checkDead(methodValue).updateAttachment(MethodValueAttachment ))
5361
+ case methodValue => typedEta(checkDead(context, methodValue).updateAttachment(MethodValueAttachment ))
5356
5362
}
5357
5363
case Typed (expr, tpt) =>
5358
5364
val tpt1 = typedType(tpt, mode) // type the ascribed type first
0 commit comments