-
Notifications
You must be signed in to change notification settings - Fork 11
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
Improve duplicate imports #1196
Conversation
@@ -25,11 +25,11 @@ object NameKind { | |||
|
|||
def externals[T](from: Package.Typed[T]): Iterable[ExternalDef[T]] = { | |||
val prog = from.program | |||
prog.externalDefs.to(LazyList).map { n => | |||
prog._1.externalDefs.to(LazyList).map { n => |
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.
Use the implicit class methods in this file
@@ -39,12 +39,6 @@ final case class Package[A, B, C, +D]( | |||
case _ => false | |||
} | |||
|
|||
// TODO, this isn't great |
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 was fixed
@@ -155,7 +154,7 @@ object Package { | |||
inferred.mapProgram(_ => ()).replaceImports(Nil) | |||
|
|||
def setProgramFrom[A, B](t: Typed[A], newFrom: B): Typed[A] = |
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.
Remove this and just inline it in the one place it is used.
@@ -468,7 +467,7 @@ object Package { | |||
val tpes = Doc.text("types: ") + Doc | |||
.intercalate( | |||
Doc.comma + Doc.line, | |||
pack.program.types.definedTypes.toList.map { case (_, t) => | |||
pack.program._1.types.definedTypes.toList.map { case (_, t) => |
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.
Use implicit class
def externalDefs: List[Identifier.Bindable] = | ||
pack.program._1.externalDefs | ||
|
||
def localImport(n: Identifier): Option[(Package.Interface, ImportedName[NonEmptyList[Referant[Kind.Arg]]])] = |
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.
Indentation
val candidates = | ||
nearest(iname.originalName, exportMap, 3) | ||
.map(ident => Doc.text(ident._1.sourceCodeRepr)) | ||
|
||
val near = Doc.text(" Nearest: ") + |
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.
Check that candidates is nonEmpty
@@ -313,9 +321,24 @@ object PackageMap { | |||
Memoize.memoizeDagFuture[ResolvedU, Ior[NonEmptyList[ | |||
PackageError | |||
], (TypeEnv[Kind.Arg], Package.Inferred)]] { | |||
// TODO, we ignore importMap here, we only check earlier we don't |
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.
Fixed this TODO
|
||
def resolvedImports: ImportMap[Package.Resolved, Unit] = | ||
imps.traverse[cats.Id, Package.Resolved, Unit] { (p, i) => | ||
(nameToRes(p), i) |
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 apply should be safe since we have constructed this ImportMap from the same source.
Add a comment with this explanation
val inferImports: FutVal[List[ImpRes]] = | ||
imports.parTraverse(stepImport(_)) | ||
val inferImports: FutVal[ImportMap[Package.Interface, NonEmptyList[Referant[Kind.Arg]]]] = | ||
resolvedImports.traverse(stepImport(_, _)) |
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.
Make sure this is using Parallel Applicative
I noticed if I made a duplicate import that does not exist to a name that collides with a predef name, the error message is bad.
I should add a test exercising this error message to be sure. There were two things: