Skip to content

Conversation

@lihaoyi
Copy link
Contributor

@lihaoyi lihaoyi commented Jan 14, 2026

Attempts to fix #24037. Vibe coded

Claude's explanation

Root Cause: The isStructuralTermSelectOrApply function in TreeInfo.scala was treating calls to dynamic methods (selectDynamic, applyDynamic, etc.) as structural calls when the symbol lookup failed. This caused handleStructural to be called recursively, creating an infinite loop.

Fix: Added a guard in isStructuralTermSelectOrApply to exclude calls where the method name is one of the dynamic method names (applyDynamic, selectDynamic, updateDynamic, applyDynamicNamed). This prevents treating already-handled dynamic method calls as structural calls, breaking the infinite recursion.

Changes Made

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala:
def isDynamicMethod(name: Name): Boolean =
name == nme.applyDynamic || name == nme.selectDynamic ||
name == nme.updateDynamic || name == nme.applyDynamicNamed

// Added check: && !isDynamicMethod(tree.name)

tests/neg/i24037.scala (new test file):

  • Test case 1: Original issue - illegal applyDynamic signature with only one parameter list
  • Test case 2: Method call with illegal applyDynamic
  • Test case 3: Wrong return type on selectDynamic

@lihaoyi lihaoyi marked this pull request as draft January 14, 2026 17:18
@lihaoyi lihaoyi marked this pull request as ready for review January 15, 2026 00:07
@lihaoyi
Copy link
Contributor Author

lihaoyi commented Jan 15, 2026

This should be ready for review I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler crashes when illegal signature of applyDynamic is used

2 participants