-
-
Save lemastero/589be3f4b0bd46e91045a4b22ad39d0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dotty.tools.dotc.ast.tpd.TypeTree | |
import dotty.tools.dotc.core.Contexts.Context | |
import dotty.tools.dotc.core.Symbols.defn | |
import dotty.tools.dotc.plugins.{PluginPhase, StandardPlugin} | |
import dotty.tools.dotc.typer.FrontEnd | |
import dotty.tools.dotc.report | |
class InferenceMatchablePlugin extends StandardPlugin { | |
override def name = "inference-matchable-plugin" | |
override def description = "warn Matchable" | |
override def init(options: List[String]): List[PluginPhase] = { | |
(new InferenceMatchablePhase()) :: Nil | |
} | |
} | |
class InferenceMatchablePhase extends PluginPhase { | |
override def phaseName = "inference-matchable" | |
override val runsAfter = Set(FrontEnd.name) | |
override def prepareForTypeTree(tree: TypeTree)(using context: Context): Context = { | |
if (tree.tpe == defn.MatchableType) { | |
report.warning("Matchableに推論されてるぞ!!!", tree.srcPos) | |
} | |
context | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment