-
Notifications
You must be signed in to change notification settings - Fork 90
Avoid assigning null to vars of derived value type #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,19 @@ private[async] trait TransformUtils { | |
} | ||
} | ||
|
||
def mkZero(tp: Type): Tree = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can add a comment with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully this can just turn into a quasiquote when I merge it to |
||
if (tp.typeSymbol.isDerivedValueClass) { | ||
val argZero = mkZero(tp.memberType(tp.typeSymbol.derivedValueClassUnbox).resultType) | ||
val target: Tree = gen.mkAttributedSelect( | ||
typer.typedPos(macroPos)( | ||
New(TypeTree(tp.baseType(tp.typeSymbol)))), tp.typeSymbol.primaryConstructor) | ||
val zero = gen.mkMethodCall(target, argZero :: Nil) | ||
gen.mkCast(zero, tp) | ||
} else { | ||
gen.mkZero(tp) | ||
} | ||
} | ||
|
||
// ===================================== | ||
// Copy/Pasted from Scala 2.10.3. See SI-7694. | ||
private lazy val UncheckedBoundsClass = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.