-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add choice collisions in scala name collision checker #11528
Changes from 2 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 |
---|---|---|
|
@@ -4,8 +4,7 @@ | |
package com.daml.lf.validation | ||
|
||
import com.daml.lf.data.Ref | ||
import com.daml.lf.data.Ref.{DottedName, ModuleName, Name} | ||
import com.daml.lf.language.Ast | ||
import com.daml.lf.data.Ref.{DottedName, ModuleName, Name, ChoiceName, TypeConName} | ||
import com.daml.lf.validation.Util._ | ||
|
||
sealed trait NamedEntity extends Product with Serializable { | ||
|
@@ -17,13 +16,12 @@ sealed trait NamedEntity extends Product with Serializable { | |
object NamedEntity { | ||
|
||
final case class NModDef( | ||
name: ModuleName, | ||
dfns: List[(DottedName, Ast.Definition)], | ||
name: ModuleName | ||
) extends NamedEntity { | ||
|
||
def modName: ModuleName = name | ||
|
||
def fullyResolvedName: DottedName = name.toUpperCase | ||
val fullyResolvedName: DottedName = name.toUpperCase | ||
|
||
override def toString = s"NModDef($name)" | ||
|
||
|
@@ -33,7 +31,6 @@ object NamedEntity { | |
final case class NRecDef( | ||
module: NModDef, | ||
name: DottedName, | ||
dfn: Ast.DDataType, | ||
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. These 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. 🙈 |
||
) extends NamedEntity { | ||
|
||
def modName: ModuleName = module.name | ||
|
@@ -49,7 +46,6 @@ object NamedEntity { | |
final case class NVarDef( | ||
module: NModDef, | ||
name: DottedName, | ||
dfn: Ast.DDataType, | ||
) extends NamedEntity { | ||
|
||
def modName: ModuleName = module.name | ||
|
@@ -65,7 +61,6 @@ object NamedEntity { | |
final case class NEnumDef( | ||
module: NModDef, | ||
name: DottedName, | ||
dfn: Ast.DDataType, | ||
) extends NamedEntity { | ||
|
||
def modName: ModuleName = module.name | ||
|
@@ -146,7 +141,6 @@ object NamedEntity { | |
final case class NInterface( | ||
module: NModDef, | ||
name: DottedName, | ||
dfn: Ast.DDataType, | ||
) extends NamedEntity { | ||
|
||
def modName: ModuleName = module.name | ||
|
@@ -158,4 +152,39 @@ object NamedEntity { | |
|
||
def pretty: String = s"interface $modName:$name" | ||
} | ||
|
||
final case class NChoice( | ||
module: NModDef, | ||
tplName: DottedName, | ||
choiceName: ChoiceName, | ||
) extends NamedEntity { | ||
def modName = module.modName | ||
|
||
val fullyResolvedName: DottedName = | ||
module.fullyResolvedName ++ tplName.toUpperCase + Name.assertFromString( | ||
choiceName.toUpperCase | ||
) | ||
|
||
override def toString: String = s"NChoice($modName:$tplName.$choiceName)" | ||
sofiafaro-da marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def pretty: String = s"template choice $modName:$tplName.$choiceName" | ||
sofiafaro-da marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
final case class NChoiceViaInterface( | ||
module: NModDef, | ||
tplName: DottedName, | ||
choiceName: ChoiceName, | ||
iface: TypeConName, | ||
) extends NamedEntity { | ||
def modName = module.modName | ||
|
||
val fullyResolvedName: DottedName = | ||
module.fullyResolvedName ++ tplName.toUpperCase + Name.assertFromString( | ||
choiceName.toUpperCase | ||
) | ||
|
||
override def toString: String = s"NChoiceViaInterface($modName:$tplName.$choiceName, $iface)" | ||
sofiafaro-da marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def pretty: String = s"template choice $modName:$tplName.$choiceName (via interface $iface)" | ||
sofiafaro-da marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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.
This value gets reused a lot, so it's better for it to be a
val
instead of adef
in this case, if I understand correctly.