[Mentorship program] Is there a way to backtrack the diagnostics emitted by the compiler?

Let's say we have a .swift file like this:

class Square {
  var perimeter: Double
  var sideLength: Double

  init(sideLength: Double) {
    self.sideLength = sideLength
    self.perimeter = 4.0 * sideLength
  }
}

class SmartSquare: Square {
  override func perimeter() -> Double {

  }
}

Compiling this file results in an error:

main.swift:12:17: error: method does not override any method from its superclass
  override func perimeter() -> Double {
  ~~~~~~~~      ^

Is there a way to backtrack every piece of code of the Swift compiler that results in emitting this diagnostic?

I'm trying to solve [SR-15176] and I have no idea where to begin. I think that if I could see the whole process that leads the compiler to emit that error, I could understand where in the process to make changes to get the wanted results, but I'm kinda stuck

This is documented in DebuggingTheCompiler.md. I included a link below. I would suggest looking at that document when you run into things like this.

1 Like