Class TraitMethodConflictDetector

java.lang.Object
org.ek9lang.compiler.phase5.TraitMethodConflictDetector

final class TraitMethodConflictDetector extends Object
Detects when multiple traits implemented by an aggregate have methods with the same signature. When this occurs, the developer MUST manually override the method to resolve the conflict. This is NOT an anti-pattern - it's a required language feature.

This detector is used to EXCLUDE conflicting methods from E11023 (Missing 'by' delegation) detection. If a method must be manually implemented due to trait conflicts, it should not be flagged as "missing by delegation".

Example of trait conflict:

trait Logger
  log() abstract -> message as String

trait Auditor
  log() abstract -> message as String  // Same signature!

class MyClass with trait of Logger, Auditor
  // MUST manually override log() - cannot use 'by' for both
  override log() -> message as String
    // Custom implementation combining both
  • Constructor Details

    • TraitMethodConflictDetector

      TraitMethodConflictDetector()
  • Method Details

    • findConflictingMethodSignatures

      Set<String> findConflictingMethodSignatures(IAggregateSymbol aggregate)
      Find method signatures that appear in multiple traits implemented by this aggregate.
      Parameters:
      aggregate - The aggregate implementing traits
      Returns:
      Set of method signatures (name + parameter types) that conflict across traits
    • hasConflict

      boolean hasConflict(IAggregateSymbol aggregate, String methodName)
      Check if a specific method (by name) has a conflict across traits.
      Parameters:
      aggregate - The aggregate implementing traits
      methodName - The method name to check
      Returns:
      true if this method name conflicts across multiple traits